define(['durandal/app', 'knockout'], function (app, ko) {
	function exports(name) {
		this.name = ko.observable(name);
		this.received = ko.observableArray([]);
		this.subscription = ko.observable();
	}
	exports.prototype.subscribe = function () {
		var sub = app.on('event:message').then(function (message) {
			this.received.push(message);
		}, this)
		this.subscription(sub);
		app.showMessage("订阅");
	}
	exports.prototype.unsubscribe = function () {
		app.showMessage("取消订阅");
		this.subscription().off();
		this.subscription(null);
	}
	return exports;
})